package com.pw.study.flow

import scala.util.control.Breaks

object While {
  def main(args: Array[String]): Unit = {
    w4()
  }

  /**
   * Continue
   */
  def w4(): Unit = {
    for (i <- 1 to 10) {
      Breaks.breakable {
        if (i == 5) {
          println("这是continue。。。。")
          Breaks.break()
        }
        println(s"......${i}")
      }
    }
  }

  /**
   * break
   */
  def w3(): Unit = {
    Breaks.breakable {
      for (i <- 1 to 10) {
        if (i == 5) {
          println("数字是5")
          Breaks.break()
        }
        println(s"............${i}")
      }
    }
  }

  /**
   * do while
   */
  def w2(): Unit = {
    var num = 0
    do {
      print(s"${num} num ")
      num += 1
    } while (num < 10)
  }

  /**
   * 循环数据
   */
  def w1(): Unit = {
    var i = 0
    while (i < 10) {
      print(s"${i} ")
      i += 1
    }
  }

}
